
      package com.pegasusexport.www.Codegen
      {
        import weborb.data.*;

        import mx.rpc.AsyncToken;
        import mx.rpc.Responder;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.remoting.RemoteObject;

        import com.pegasusexport.www.Product;
        import com.pegasusexport.www.DataMapperRegistry;
      
        public dynamic class _ProductDataMapper extends DataMapper
        {
        
          public override function createActiveRecordInstance():ActiveRecord
          {
            return new Product();
          }
        
          protected override function get RemoteClassName():String
          {
            return "com.pegasusexport.www.ProductDataMapper";
          }
          
          public function load(product:Product, responder:Responder = null):Product
          {
              if(!product.IsPrimaryKeyInitialized)
          	    throw new Error("Record can be loaded only with initialized primary key");
          
              if(IdentityMap.exists(product.getURI()))
              {
                product = Product(IdentityMap.extract(product.getURI()));
                
                if(product.IsLoaded || product.IsLoading)
                  return product;
              } 
              else
               IdentityMap.add(product);

              var asyncToken:AsyncToken = new DatabaseAsyncToken(createRemoteObject().findByPrimaryKey(product.Id),null,product);

              return product;
           }

           public function findByPrimaryKey(id:int):Product
           {
              var activeRecord:Product = new Product();

              activeRecord.Id = id;

              return load(activeRecord);
           }

           public override function loadChildRelation(activeRecord:ActiveRecord,relationName:String, activeCollection:ActiveCollection):void
           {
              var item:Product = Product(activeRecord);

           }
        }  
      }